<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <counter></counter>
      <div>
        <Counter></Counter>
        
      </div>
      <box-ciy></box-ciy>
    </div>

    <template id="counter">
      <button @click="count++">一共点击了{{count}}次</button>
    </template>

    <template id="box">
      <div style="width: 200px; height: 200px; background-color: red;">
        盒子组件
        <counter></counter>
        </div>
    </template>
    <script src="../js/vue.js"></script>

    <script>
      //注册局部组件
      const Counter = {
        data(){
          return {
            count:0
          }
        },
        template:"#counter",
      };

      const Box = {
        //组件选项
        components:{
          'counter':Counter,
          
        },
        template:"#box"
      }


      const app = Vue.createApp({
        data() {
          return {
            msg: ""
          }
        },
        components:{
          'counter':Counter,//必须要渲染了才能使用
          'box-ciy':Box,
        }
      }).mount("#app");
    </script>
  </body>
</html>